@model LogListViewModel
@using SF.Web.Pagination
@addTagHelper "*, SF.Web.Pagination"
@using SF.Module.LoggingStorage.ViewModels
@using Microsoft.Extensions.Localization
@using SF.Core.Localization
@using SF.Module.LoggingStorage.Services
@inject IStringLocalizer<LogManager> sr
@inject ITimeZoneHelper tzHelper
@functions
{
    public string GetClassFromLogLevel(string logLevel)
    {
        switch (logLevel)
        {
            case "Error":
            case "Critical":
                return "bg-danger";

            case "Warning":
                return "bg-warning";

            case "Information":
            default:
                return "bg-info";
        }
    }

    public string GetButtonClass(string logLevel, string buttonLogLevel)
    {
        switch (logLevel)
        {
            case "Critical":
            case "Error":
                if (buttonLogLevel == logLevel)
                {
                    return "btn btn-danger";
                }
                return "btn btn-default";

            case "Warning":
                if (buttonLogLevel == logLevel)
                {
                    return "btn btn-warning";
                }
                return "btn btn-default";

            case "Information":
            case "":
            default:
                if (buttonLogLevel == logLevel)
                {
                    return "btn btn-info";
                }
                return "btn btn-default";
        }
    }
}
<h1>@ViewData["Heading"]</h1>
<a class="@GetButtonClass(Model.LogLevel, "Critical")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Critical">@sr["Critical"]</a>
<a class="@GetButtonClass(Model.LogLevel, "Error")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Error">@sr["Error"]</a>
<a class="@GetButtonClass(Model.LogLevel, "Warning")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Warning">@sr["Warning"]</a>
<a class="@GetButtonClass(Model.LogLevel, "Information")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Information">@sr["Information"]</a>
<a class="@GetButtonClass(Model.LogLevel, "Debug")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Debug">@sr["Debug"]</a>
<a class="@GetButtonClass(Model.LogLevel, "Trace")" role="button" asp-controller="SystemLog" asp-action="Index" asp-route-logLevel="Trace">@sr["Trace"]</a>
<a class="@GetButtonClass(Model.LogLevel, "")" role="button" asp-controller="SystemLog" asp-action="Index">@sr["All"]</a>
<ul class="list-unstyled">
    @foreach (var item in Model.LogPage)
    {
        <li class="@GetClassFromLogLevel(item.LogLevel)">
            <form role="form" class="form-inline" asp-controller="SystemLog" asp-action="LogItemDelete">
                <input type="hidden" id="id" name="id" value="@item.Id" />
                <input type="submit" value='@sr["Delete"]' class="btn btn-xs btn-default pull-left" />
            </form>
            <h2 class="logitem">
                @tzHelper.ConvertToLocalTime(item.LogDateUtc, Model.TimeZoneId).ToString()
                <strong>@item.LogLevel</strong>
                @item.IpAddress
                @item.Logger
                @item.ShortUrl
            </h2>
            <p>
                @Html.Encode(item.Message)
            </p>
        </li>
    }
</ul>
<div>
    <cs-pager cs-paging-info="@Model.Paging"
              asp-action="Index" asp-controller="SystemLog"
              asp-route-logLevel="@Model.LogLevel"
              asp-route-pagesize="@Model.Paging.ItemsPerPage"></cs-pager>
</div>
<form role="form" class="form-inline" asp-controller="SystemLog" asp-action="LogDeleteAll">
    <a asp-action="Index" class="btn btn-sm btn-default ">@sr["Refresh"]</a>
    <input type="hidden" asp-for="@Model.LogLevel" />
    <input type="submit" value='@sr["Clear Log"]' class="btn btn-sm btn-danger " />
</form>
<form role="form" class="form-inline" asp-controller="SystemLog" asp-action="LogDeleteOlderThan">
    <input type="hidden" asp-for="@Model.LogLevel" />
    <input type="submit" value='@sr["Delete Older Than"]' class="btn btn-sm btn-danger " />
    <select class="form-control" name="days" id="days">
        <option>1</option>
        <option>5</option>
        <option>10</option>
        <option>30</option>
        <option>60</option>
    </select>
    @sr["Days"]
</form>
